//
//  GYZFreeTabelViewCell.m
//  Qyer
//
//  Created by GYz on 15/10/20.
//  Copyright © 2015年 GF. All rights reserved.
//

#import "GYZFreeTabelViewCell.h"

@implementation GYZFreeTabelViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.photoView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH/3, SCREEN_WIDTH * 3/12)];
        [self.contentView addSubview:self.photoView];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.photoView.frame.size.width + 20, 0, SCREEN_WIDTH/3*2 - 20, SCREEN_HEIGHT/10)];
        [self.titleLabel setNumberOfLines:2];
        self.titleLabel.font = [UIFont systemFontOfSize:15.];
        [self.contentView addSubview:self.titleLabel];
        
        self.priceoffLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.photoView.frame.size.width +15, self.photoView.frame.size.height - 20, 60, 30)];
        self.priceoffLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.priceoffLabel];
        
        self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/4*3, self.photoView.frame.size.height - 25, SCREEN_WIDTH/4, 40)];
        self.priceLabel.textColor = [UIColor redColor];
        [self.contentView addSubview:self.priceLabel];
    }
    return self;
}

- (void)setValueWithModel:(GYZFreeModel *)model
{
    NSURL *url = [NSURL URLWithString:model.photo];
    [self.photoView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"zhanweiPic"]];
    self.titleLabel.text = model.title;
    self.priceoffLabel.text = model.priceoff;
    NSString *str =[model.price substringWithRange:NSMakeRange(4, model.price.length - 4 - 7)];
    NSString *string = [NSString stringWithFormat:@"%@元起",str];
    self.priceLabel.text = string;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
